Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error wrapper to conform any error type to IdentifiableError #182

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

Jeehut
Copy link
Contributor

@Jeehut Jeehut commented Sep 5, 2024

This significantly improves the ease of use of the new error handling preset in the SwiftSDK. I wrote the helper added in this PR in my last app and it saved me a lot of repetitive code. I think it would make sense to ship as part of the SDK.

If merged, I can update the docs accordingly.

With this PR merged, rather than writing something like this every time I catch an error:

do {
  // ...
} catch {
  TelemetryDeck.errorOccurred(
    id: "SeriesRenamer.loadItemFailed", 
    category: .thrownException, 
    message: error.localizedDescription
  )
}

I can write this instead, saving unnecessary typing in many places:

do {
  // ...
} catch {
  TelemetryDeck.errorOccurred(
    identifiableError: error.with(id: "SeriesRenamer.loadItemFailed")
  )
}

@Jeehut Jeehut force-pushed the feature/any-error branch 2 times, most recently from 6fce839 to ce74597 Compare September 5, 2024 14:58
@Jeehut Jeehut changed the title Add AnyError type to conform any error type to IdentifiableError Add error wrapper to conform any error type to IdentifiableError Sep 5, 2024
Copy link
Contributor

@winsmith winsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this! At some point we'll have to consolidate this with our plans on MetricKit and general error tracking, but this is a really good direction!

@Jeehut Jeehut merged commit 2c9ec7c into main Sep 9, 2024
6 checks passed
@Jeehut Jeehut deleted the feature/any-error branch September 9, 2024 16:08
@Jeehut
Copy link
Contributor Author

Jeehut commented Sep 9, 2024

@winsmith We can talk about MetricKit in a call if you want to me to help realize it in the near future. I am available to work even more than currently agreed right now in case you need me to, as it sounds like a bigger task to me.

Having that said, I also need your decision for this PR: Do you think enough time has passed since the Swift 6 PR merged that we can make a new release? I have used the main branch in my apps without problems myself, but I don't know if you heard about any problems from other customers.

I created a new issue (TelemetryDeck/docs#101) for the docs update. But I'll wait until a new SDK release was made (otherwise customers could get confused).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants